<?php
class Atur_syahriyah extends CI_Model 
{

	function __construct()
	{
		parent::__construct();
	}

	function jenjang($id_mr_th_ajaran)
	{
		$this->db->select('id_a_sy, a_sy.id_m_th_ajaran, th_ajaran, a_sy.id_m_j_pendidikan, j_pendidikan, besar_sy');
		$this->db->from('a_sy');
		$this->db->join('m_th_ajaran', 'm_th_ajaran.id_m_th_ajaran = a_sy.id_m_th_ajaran');
		$this->db->join('m_j_pendidikan', 'm_j_pendidikan.id_m_j_pendidikan = a_sy.id_m_j_pendidikan');
		$this->db->where('a_sy.id_m_th_ajaran', $id_mr_th_ajaran);
		$this ->db->order_by('a_sy.id_m_j_pendidikan');

		$query = $this->db->get();		
		return $query->result();
	}
	
	function jp_th_ajar($id_m_th_ajaran)
	{
		$this->db->select('*');
		$this->db->from('m_j_pendidikan');
		$this->db->where('id_m_j_pendidikan not in (select id_m_j_pendidikan from a_sy where id_m_th_ajaran = '.$id_m_th_ajaran.')');
		$this ->db->order_by('id_m_j_pendidikan');

		$query = $this->db->get();		
		return $query->result();
	}
	
	function save($dataInsert)
	{
		$query = $this->db->insert('a_sy', $dataInsert);
		return $query;
	}
	
	function delete($id_a_sy)
	{
		$this->db->where('id_a_sy', $id_a_sy);
		$delete = $this->db->delete('a_sy');
		return $delete;
	}
}